"""
FileName：request_token.py
Description：
Author：gaojiahui
Time：2025/8/14 15:58
Website：https://gitee.com/gao-jiahui
"""

from auth_manager import AuthManager

"""Token在请求中的使用"""
# 使用认证头调用用户信息接口
def get_current_user(auth_manager):
    url = f"{auth_manager.base_url}/admin/user/info"
    headers = auth_manager.get_auth_headers()

    response = auth_manager.session.get(url,headers=headers)

    if response.status_code == 200:
        return response.json()
    return None

# 使用示例
auth_manager = AuthManager("http://pig-gateway:9999")
if auth_manager.login("admin","YehdBPev"):
    user_info = get_current_user(auth_manager)
    print(f"当前用户:{user_info}['username")